package org.zjt.hessian.demo.client;


import org.assertj.core.api.BDDAssertions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.zjt.hessian.demo.common.domain.Foo;
import org.zjt.hessian.demo.common.service.HelloService;

/**
 * 测试远程hessian调用。
 */
@IntegrationTest
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {HessianFactoryBeanConfig.class})
public class ApplicationClientTest {

    /**
     * 从远程的Hessian的IOC中，得到该Bean。
     */
    @Autowired
    private HelloService helloClient;


    @Test
    public void shouldSayHello() {
        //when
        String message = helloClient.sayHello();

        System.out.println(message);
        BDDAssertions.then(message).isNotEmpty().isEqualTo("Hello World");
    }



    @Test
    public void shouldReceiveFoo() {
        //when
        Foo foo = helloClient.foo();

        System.out.println(foo.toString());
        BDDAssertions.then(foo.getName()).isEqualTo("foo");
    }

}
